package com.woniuxy.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.entity.Area;
import com.woniuxy.service.AreaService;



import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.dto.PageDto;
import com.woniuxy.entity.Area;
import com.woniuxy.service.AreaService;
import com.woniuxy.utils.Result;

@RestController //所有数据默认以json返回  @controller + @responsebody
@RequestMapping("/area")
public class AreaController {
	
	@Autowired
	private AreaService areaService;
	
	@RequestMapping("/find")
	public PageDto<Area> findAllArea(Integer page){
		return areaService.findAllArea(page);
	}
	
	@GetMapping("/findArea")
	public List<Area> findArea(){
		return areaService.findArea();
	}
	
	@RequestMapping("/add")
	public int addArea(Area area) {	
		return areaService.addArea(area);
	}
	
	@RequestMapping("/findAreaByStatus")
	public PageDto<Area> findAreaByStatus(Integer status,Integer page){
		return areaService.findAreaByStatus(status, page);		
	}
	
	@RequestMapping("/search")
	public PageDto<Area> searchAreaByAname(String name,Integer page){		
		return areaService.findAreaByAname(name, page);		
	}
	
	@RequestMapping("/delete")
	public PageDto<Area> deleteAreaByAid(Integer aid,Integer page){
		areaService.deleteAreaByAid(aid);
		PageDto<Area> areas = areaService.findAllArea(page);
		return areas;
	}
	
	@RequestMapping("/updateSwitch")
	public int updateSwitch(Integer aid, Integer value) {
		return areaService.updateSwitch(aid, value);	
	}
		
	
}
